package extend.接口;

import java.util.Scanner;

//果汁的接口
public interface Fruit {
    //由你好果汁吃
    void product();
}

class Apple implements Fruit {
    @Override
    public void product() {
        System.out.println("苹果");
    }
}

class Banana implements Fruit {
    @Override
    public void product() {
        System.out.println("香蕉");
    }
}

class TestFruit {
    public static void main(String[] args) {
        System.out.println("请输入你需要的果汁 1，苹果 2.橡胶");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        Fruit fruit = null;
        switch (num) {
            case 1:
                fruit = new Apple();
                break;
            case 2:
                fruit = new Banana();
                break;
            default:
                System.out.println("没有这个果汁");
        }
        fruit.product();
    }
}